package com.hhkj.admin.course.service.base.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hhkj.admin.course.domain.CoursePriceConf;
import com.hhkj.admin.course.model.dopo.CoursePriceConfDo;
import com.hhkj.admin.course.model.dopo.CoursePriceConfPo;
import com.hhkj.admin.course.service.base.CoursePriceConfService;
import com.hhkj.admin.course.mapper.CoursePriceConfMapper;
import com.ruoyi.common.base.biz.service.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author admin
* @description 针对表【s_course_price_conf(课程价格默认题库的价格套餐)】的数据库操作Service实现
* @createDate 2023-10-24 18:11:44
*/
@Service
public class CoursePriceConfServiceImpl extends BaseServiceImpl<CoursePriceConf, CoursePriceConfDo, CoursePriceConfPo, CoursePriceConfMapper>
    implements CoursePriceConfService {

    @Override
    public Map<Long, List<CoursePriceConf>> groupByCourseIdList(List<Long> courseIdList) {
        if (ObjectUtil.isEmpty(courseIdList)) {
            return new HashMap<>();
        }
        LambdaQueryWrapper<CoursePriceConf> queryWrapper = new LambdaQueryWrapper<CoursePriceConf>()
                .in(CoursePriceConf::getCourseId, courseIdList);

        return list(queryWrapper).stream().collect(Collectors.groupingBy(CoursePriceConf::getCourseId));
    }

    @Override
    public List<CoursePriceConf> listByIdList(List<Long> idList) {
        if(ObjectUtil.isEmpty(idList)) {
            return new ArrayList<>();
        }
        LambdaQueryWrapper<CoursePriceConf> queryWrapper = new LambdaQueryWrapper<CoursePriceConf>()
                .in(CoursePriceConf::getId, idList);
        return list(queryWrapper);
    }
}




